package edu.ucdavis.gwt.gis.client.extras;

import com.google.gwt.dom.client.Style.Float;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;

import edu.ucdavis.cstars.client.InfoWindowBase;


public class GwtGisInfoWindow extends InfoWindowBase  {

        
        private DisclosurePanel wrapper = new DisclosurePanel();
        private HTML title = new HTML("");
	    private HTML content = new HTML();
	    
	    public GwtGisInfoWindow() {
	            load();
	    }
	    
	    @Override
	    public void init() {
            wrapper.setWidth("250px");
            
            wrapper.setAnimationEnabled(true);
            wrapper.setContent(content);
            wrapper.setHeader(title);
            title.getElement().getStyle().setProperty("whiteSpace", "nowrap");
            
            FlowPanel fp = new FlowPanel();
            //fp.setStyleName(GadgetResources.INSTANCE.css().InfoWindow());
            fp.setStyleName("innerMapPopup");
            
            CloseButton close = new CloseButton();
            close.addClickHandler(new ClickHandler(){
				@Override
				public void onClick(ClickEvent event) {
					hide();
				}
            });
            close.getElement().getStyle().setFloat(Float.RIGHT);
            fp.add(close);
            fp.add(wrapper);
            
            getPanel().add(fp);
        }

        @Override
        public void onHide() {}

        @Override
        public void onShow() {
                wrapper.setOpen(true);
        }

		@Override
		public void setContent(String content) {
			this.content.setHTML(content);
		}

		@Override
		public void setTitle(String title) {
			this.title.setHTML(title);
		}
	
}
